<template>
  <div class="bottom-left-container">
    <div class="line-header">
      <icon-font icon-class="afl-xuanze"></icon-font>
      {{ $t('wms.lineSelect') }}
    </div>
    <div class="tabBox">
      <div class="tab-item" v-for="(item, index) in data.line" :key="index" @click="changeIndex(index)">
        <div :class="data.tabIndex == index ? 'tab-choice' : ''">{{ item.productionLineCode }}</div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { onMounted, reactive, ref, watch } from 'vue'
import iconFont from '@/components/IconFont/iconFont'
import { getProcessLineById } from '@/api/mesApi'

const data = reactive({
  tabIndex: 0,
  line: []
})

onMounted(() => {
  getProcessLine()
  setTime()
})
// 定时执行
const setTime = () => {
  setInterval(async () => {
    await getProcessLine
  }, 6000)
}
const changeIndex = (index) => {
  data.tabIndex = index
}

const getProcessLine = () => {
  getProcessLineById({ processId: 4, rows: 100 }).then(function (res) {
    console.log(res)
    data.line = res.rows
  })
}
</script>

<style scoped lang="scss">
.bottom-left-container {
  height: 100%;
  width: 100%;
  margin-right: 10px;
  overflow: hidden;
  box-sizing: border-box;
  background-color: #fff;
  display: flex;
  flex-direction: column;
  overflow: auto;

  .line-header {
    box-sizing: border-box;
    background: linear-gradient(90deg, #3dadf6, #737bfc);
    font-size: var(--el-font-size-extra-large);
    line-height: 2;
    font-weight: bold;
    padding-left: 20px;
    color: white;

    .iconfont {
      font-size: 22px;
    }
  }

  .tabBox {
    flex: 1;
    box-sizing: border-box;
    overflow: auto;
  }

  .tab-item {
    height: 50px;
    line-height: 50px;
    font-size: 18px;
    padding: 5px 5px 2px 15px;
    position: relative;
    text-align: center;
    transition-property: background-color, width;
    background-color: #fff;
    text-align: left;
    margin-bottom: 10px;
    box-sizing: border-box;
    letter-spacing: 1.5px;
  }

  .tab-choice {
    position: relative;
    color: #f40;
  }

  .tab-choice:before {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    border-radius: 1px;
    background-color: #f40;
  }
}
</style>
